<?php
include_once "BaseM.php";
 
class PushM extends BaseM{
	
	private $table = "member";
	private $logTable = "member";
	
	public function __construct() {
		parent::__construct ();
	}
	
	public function queryTable($orderData, $startPage, $pageRow, $searchStr) {
		
		$whereStr = " is_delete = 0 $searchStr ";
		
		$countSql = "select count(id) as count from $this->table where $whereStr ";
		$count = $this->querySQL($countSql, true);
		
		$resultSql = "
			select 
				id, account, regist_type, m_type, gender, live_zone, county, push_status,
				case regist_type when 1 then '一般註冊'
								 when 2 then 'Facebook 註冊'
								 when 3 then 'G+註冊'
								 when 0 then '註冊錯誤'
				end regist_type2,
				case m_type when 1 then 'Android'
							when 2 then 'iOS'
				end m_type2,
				case gender when 1 then '男'
							when 2 then '女'
							when 0 then '未登錄'
				end gender2,
				case live_zone when 1 then '北部'
							   when 2 then '中部'
							   when 3 then '南部'
							   when 4 then '東部'
							   when 5 then '離島'
							   when 6 then '其他'
							   when 0 then '未登錄' 
				end live_zone2,
				(select count(id) from cat where member_id = m.id) as catCount,
				(select count(id) from dog where member_id = m.id) as dogCount
			from $this->table as m
			where $whereStr
			order by $orderData 
			limit $startPage, $pageRow ";
		$result = $this->querySQL($resultSql);
		
		return array( "count" => $count->count, "result" => $result );
	}
	
	public function queryPush($searchStr) {
	
		$whereStr = " push_status = 1 $searchStr ";
	
		$resultSql = "
			select
				m_type, push_no
			from $this->table
			where $whereStr 
			group by push_no ";
		$result = $this->querySQL($resultSql);
	
		return $result;
	}
	
}

?>